The present invention relates to a method and apparatus for measuring or inspecting a circular arc configuration of a product or part such as the circular arc configuration of a thread hole, and more particularly to a method for approximating the center position and radius of the circular arc configuration based on image information.
With reference to the drawings, two examples of conventional method for approximating a circular are configuration are is described below.
The conventional method includes the following three processes (A), (B) and (C).
Process (A):
A sequence of edge points is extracted from a two-dimensional image.
Process (B):
A point sequence is formed based on the edge points.
Process (C):
A circular-arc is approximated based on the point sequence. The circular-arc configuration of the product is detected according to the approximated circular arc.
The two examples 1 and 2 of conventional method which will be described below each include the above-described processes (A) and (B), but are different from each other with respect to process (C).
First, the process (A) for extracting edge points from the two-dimensional image is described. Normally, in measuring or inspecting the configuration of a specified portion of a product or part, there are abrupt changes in the density of the image thereof. The image density suddenly changes at the edge point. Therefore, the absolute value of the differentiated value of the image density is large at the edge point. Thus, the image is filtered by a differential filter so that a point at which the absolute value of the output is large is set as the edge point. A Laplacian filter is an example of a differential filter. FIG. 2 shows an example of an output, obtained by the use of the Laplacian filter, in which a center point having a value "8" is an edge point. In extracting ridges shown in FIG. 3 from a two-dimensional image, a result obtained by using the Laplacian filter is shown in FIG. 4. An edge point is required to satisfy two of the following four conditions.
X.gtoreq.X.sub.0 and X&gt;X.sub.4 PA1 X.gtoreq.X.sub.1 and X&gt;X.sub.5 PA1 X.gtoreq.X.sub.2 and X&gt;X.sub.6 PA1 X.gtoreq.X.sub.3 and X&gt;X.sub.7 PA1 extracting an aggregation of edge points from data of the two-dimensional image of a product or part having the circular arc to be detected, a configuration of which is measured or inspected; PA1 finding the square of the distance between the center of a circular arc and a given edge point of an aggregation of the edge points; PA1 finding the square of the radius of the circular arc used in the first finding step; PA1 finding the square of the difference between the two squares; PA1 taking a mean value of a fourth power error obtained by the square of the difference of the two squares; and PA1 minimizing the mean value of the fourth power error to perform an approximation so as to estimate a circular arc having the minimum mean value as an approximated circular arc of the circular arc to be detected in the aggregation of the edge points..
The process (B) for forming a point sequence based on edge point is now described. In order to obtain a point sequence from the aggregation of edge points obtained in the process (A), adjacent edge points are connected with each other. In this case, short lines branching from the point sequence are deleted. Of long lines branching from the point sequence, only a point sequence consisting of a branch having a minimum curvature is selected and other branches are cut off to obtain a single point sequence having no branches. The curvature (C) is calculated as follows: A branch point shown in FIG. 5 is assumed as (P). Points spaced at a length (L) from the point (P) are supposed as Q.sub.1 and Q.sub.2. When the difference in the directional angle between a vector Q.sub.1 P and a vector PQ.sub.2 is supposed as .theta., the curvature (C) is found as follows: EQU C=.theta./L (1)
The value of (L) is set to be smaller than the radius of a circumference which must be detected so that noise does not have a large inappropriate influence on calculations used for finding the curvature (C) because it is sensitive that the value is set to be too small. The resulting point sequence is expressed as follows: EQU {P.sub.i .vertline.i=1, . . . N} (2)
The process (C) for approximating a circular arc from the point sequence of the process (B) and detecting the circular arc configuration based on the approximated circular arc will now be described. Since the two examples 1 and 2 differ with respect to process (C), the example 1 is first described below. FIG. 6 is an illustration showing the method for calculating a partial curvature C.sub.i+1 of the first example 1.
The partial curvature C.sub.i+1 of a curve formed by three points P.sub.i, P.sub.i+1 and P.sub.i+2 is expressed as follows: EQU C.sub.i+1 =.theta..sub.i+1 /d.sub.i+1 ( 3)
where .theta..sub.i+1 is the difference in the directional angle between a vector (P.sub.i P.sub.i+1) and a vector (P.sub.i+1 P.sub.i+2), and d.sub.i+1 is the average of the length P.sub.i P.sub.i+1 and the length P.sub.i+1 P.sub.i+2.
The curvature C.sub.1 of the entire point sequence is expressed as follows: ##EQU1##
A decision is made according to the value of the variance of the partial curvature C.sub.i+1 with respect to the curvature C.sub.1 of the entire point sequence. If the variance value is smaller than a predetermined value, it is decided that the point sequence is a part of a circular arc and consequently, detected as the circular arc.
The process (C) of example 2 for approximating a circular arc from the point sequence of the process (B) and detecting the circular arc configuration based on the approximated circular arc will now be described. FIG. 7 is an illustration showing the method for calculating a partial curvature C.sub.i+s of the example 2.
According to the example 2, instead of calculating the partial curvature of a curve configured by the three continuous points as in the example 1, the partial curvature C.sub.i+s between two points spaced at (s) pieces of points apart is calculated. If the variance of the partial curvature C.sub.i+s with respect to the curvature C.sub.2 of the entire point sequence is smaller than a predetermined value, it is decided that the point sequence is a part of a circular arc and accordingly detected as the circular arc.
The partial curvature C.sub.i+s of the circular arc formed by three points P.sub.i, P.sub.i+s, and P.sub.i+2s of the point sequence is expressed by the following equation (5): EQU C.sub.i+1 =.theta..sub.i+1 /d.sub.i+1 ( 5)
where .theta..sub.i+s is the difference in the directional angle between a vector [P.sub.i P.sub.i+s ] and a vector [P.sub.i+s P.sub.i+2s ] and d.sub.i+s is the average of the length P.sub.i P.sub.i+s and the length P.sub.i+s P.sub.i+2s.
The curvature C.sub.2 of the entire point sequence is expressed by the following equation (6). ##EQU2##
A decision is made according to the value of the variance of the partial curvature C.sub.i+s with respect to the curvature C.sub.2 of the entire point sequence. If the value of the variance is smaller than a predetermined value, it is decided that the point sequence is a part of a circular arc and consequently is detected as the circular arc.
However, the above-described conventional method have the following disadvantages:
The disadvantage common to the examples 1 and 2 is that in the processes (A) and (B), in forming a point sequence from edge points extracted from the two-dimensional image, false edge points are generated as a result of, for example, dirt adhering to the product or part roughness of the product surface, and electric signal noise. Such false edge points do not coincide with the required true edge points of the actual configuration of the product or parts to be measured or inspected. If extraction of edge points is repeated to remove the false edge points, some of the true edge points will disappear together with the false edge points. As a result, the required edge points decrease and the point sequence becomes short. Consequently, it becomes difficult to make a correct approximation of the circular arc. In addition, edge points serving as the information source of the approximation of a circular arc decrease, and thus, the position and radius of the circular are cannot be accurately calculated.
Further, it takes a long time for the methods of examples 1 and 2 to perform the necessary calculations because a large number of angle calculations is required.
As described previously, according to the example 1, the curvature C.sub.1 of the entire point sequence is expressed by the equation (4). But supposing that d.sub.0 is the length of the entire point sequence and .theta..sub.01 is the variation from the directional angle of a vector P.sub.1 P.sub.2 connecting one edge point of the point sequence and a point adjacent thereto with each other to the directional angle of a vector P.sub.N-1 P.sub.N connecting the other edge point of the point sequence and a point adjacent thereto with each other, the curvature C.sub.1 is expressed as follows: ##EQU3##
Usually the actual outline image of a product or part is not necessarily thin, but thick. According to the above-described method for extracting edge points which uses filtering, large errors are made in determining the coordinates of edge points. In addition, since the average value d.sub.i+1 of the equation (3) is small, a large error is made in the directional angle, between the vector P.sub.1 P.sub.2 and the vector P.sub.N-1 P.sub.N, which determines the variation .theta..sub.01. Thus, a large error occurs in the calculation of the variation .theta..sub.01, namely, in the calculation of the curvature C.sub.1 of the entire point sequence.
According to the example 2, since the average value d.sub.i+s of the equation (5) is (s) times as great as the average value d.sub.i+1 of the equation (3) of the example 1, errors in determining the coordinates of edge points are not large and consequently, the error of the curvature C.sub.2 of the entire point sequence is smaller than that of the example 1. But if the number of point sequences is small, the curvature cannot be calculated depending on the value of (s). Further, according to the example 2, there is no reference value on which an appropriate value of (s) is determined.
Furthermore, according to the examples, the center of the circular arc is not found.